import { Commit } from 'vuex'
import { ADD_TODO, SET_TODOLIST, REMOVE_TODO, SET_STATUS, SET_DOING } from './actionsType'
import { IState, ITodoItem } from '@/typings'

interface ICtx {
  commit: Commit,
  state: IState
}

export default {
  [ADD_TODO]({ commit }: ICtx, todo: ITodoItem): void {
    commit(ADD_TODO, todo);
  },
  [SET_TODOLIST]({ commit }: ICtx, list: ITodoItem[]): void {
    commit(SET_TODOLIST, list);
  },
  [REMOVE_TODO]({ commit }: ICtx, id: number): void {
    commit(REMOVE_TODO, id);
  },
  [SET_STATUS]({ commit }: ICtx, id: number): void {
    commit(SET_STATUS, id);
  },
  [SET_DOING]({ commit }: ICtx, id: number): void {
    commit(SET_DOING, id);
  },
}